#pragma once

#include "InterruptibleActivityRegion.h"

#include "ActivityEdge.h"
#include "ActivityNode.h"

namespace uml {

InterruptibleActivityRegion::InterruptibleActivityRegion(const QString& umlType)
    : NamedElement(umlType) {}

void InterruptibleActivityRegion::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    NamedElement::fromJson(json, errorList);
    ActivityGroup::fromJson(json, errorList);
    JsonSerializable::fromJsonArray(interruptingEdges_, "interruptingEdges", json, errorList);
    JsonSerializable::fromJsonArray(nodes_, "nodes", json, errorList);
}

void InterruptibleActivityRegion::toJson(QJsonObject& json) {
    NamedElement::toJson(json);
    ActivityGroup::toJson(json);
    JsonSerializable::toJsonArray(interruptingEdges_, "interruptingEdges", json);
    JsonSerializable::toJsonArray(nodes_, "nodes", json);
}

/// <summary>
/// interruptingEdges getter
/// The ActivityEdges leaving the InterruptibleActivityRegion on which a traversing
/// token will result in the termination of other tokens flowing in the
/// InterruptibleActivityRegion.
/// </summary>
vector<shared_ptr<ActivityEdge>>& InterruptibleActivityRegion::interruptingEdges() {
    return interruptingEdges_;
}

/// <summary>
/// nodes getter
/// ActivityNodes immediately contained in the InterruptibleActivityRegion.
/// </summary>
vector<shared_ptr<ActivityNode>>& InterruptibleActivityRegion::nodes() {
    return nodes_;
}

} // namespace uml
